/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package utils;

import java.util.Comparator;

/**
 *
 * @author Simply
 */
public final class Weighted<T> extends Pair<T, Double> {
    public static final class DirectComparison<T> implements Comparator<Pair<T, Double>> {
        @Override
        public int compare(Pair<T, Double> o1, Pair<T, Double> o2) {
            return o1.r().compareTo(o2.r());
        }
    }
    public static final class ReverseComparison<T> implements Comparator<Pair<T, Double>> {
        @Override
        public int compare(Pair<T, Double> o1, Pair<T, Double> o2) {
            return o2.r().compareTo(o1.r());
        }
    }
    public Weighted(T l, Double r) {
        super(l, r);
    }
    public T value() { return this.l(); }
    public Double weight() { return this.r(); }

    @Override
    public String toString() {
        return this.l() + ":" + this.weight();
    }
}
